<template>
  <div class="container">
    <a-table class="table" :rowKey="row => row.id" :dataSource="list" :pagination="pagination" @change="pageChange">
      <a-table-column title="用户ID" width="30px">
        <template slot-scope="row">
          <div v-if="row.user">{{row.user.id}}</div>
        </template>
      </a-table-column>
      <a-table-column
        title="平台用户"
        key="name"
        width="100px"
      >
        <template slot-scope="row">
          <span v-if="row.user">
            <img :src="row.user.headimg" class="headimg">
            {{ row.user.name }}
            <a-tag color="red" style="margin-left:10px;" v-if="row.user.status === 2">已拉黑</a-tag>
            <a-tag color="red" style="margin-left:10px;" v-if="row.user.is_rb === 1">马甲</a-tag>
            <a-tag color="red" style="margin-left:10px;" v-if="row.user.is_rb2 === 1">主播</a-tag>
            <a-tag color="red" style="margin-left:10px;" v-if="row.user.is_liu === 1">老六</a-tag>
            <a-tag color="red" style="margin-left:10px;" v-if="row.user.is_nopay === 1">禁付</a-tag>
            <a-tag color="blue" style="margin-left:10px;" v-if="row.user.click_id">微广</a-tag>
          </span>
        </template>
      </a-table-column>
      <a-table-column title="地区" width="70px">
        <template slot-scope="row">
          <div v-if="row.visitors">{{row.visitors.province}}-{{row.visitors.city}}</div>
        </template>
      </a-table-column>
      <a-table-column title="平台手机" width="80px">
        <template slot-scope="row">
          <div v-if="row.user">{{row.user.phone}}</div>
        </template>
      </a-table-column>
      <a-table-column title="所在群" width="60px">
        <template slot-scope="row">
          <a-tag style="margin-left:10px;" v-for="(item, index) in row.groups">{{item}}</a-tag>
        </template>
      </a-table-column>
      <a-table-column title="群里昵称" width="30px">
        <template slot-scope="row">
          <div>{{ row.name}}</div>
        </template>
      </a-table-column>
      <a-table-column title="群实付" width="60px">
        <template slot-scope="row">
          <div>{{ row.paidtotal / 100}}</div>
        </template>
      </a-table-column>
      <a-table-column title="群last消费/全" width="120px">
        <template slot-scope="row">
          <div>{{ row.md_created_at}}</div>
        </template>
      </a-table-column>
      <a-table-column title="全实付" width="60px">
        <template slot-scope="row">
          <div>{{ row.paidtotal2 / 100}}</div>
        </template>
      </a-table-column>
      <a-table-column title="全last消费" width="120px">
        <template slot-scope="row">
          <div>{{ row.md_created_at2}}</div>
        </template>
      </a-table-column>
      <a-table-column title="更新时间" width="40px">
        <template slot-scope="row">
          <div>{{row.updated_at | formatDate}}</div>
        </template>
      </a-table-column>
      
    </a-table>


  </div>
</template>

<script>
  import moment from 'moment'

  export default {
    components: {

    },
    data() {
      return {
        page: 1,
        per_page: 500,
        total: 0,
        list: [],
        pagination: {
          pageSize: 20,
          current: 1,
          total: 0
        },
      }
    },
    computed: {
      
    },
    props: {
      group_id: 0
    },
    created() {
      this.fetchData();
    },
    filters: {
      formatDate (value) {
        return value ? moment(value).fromNow() : ''
      },
      formatDate2 (value) {
        return value ? moment(value).format('YYYY-MM-DD') : ''
      }
    },
    mounted() {},
    watch: {},
    methods: {
      pageChange(pagination) {
        this.pagination = pagination
        this.fetchData() 
      },
       fetchData () {
        this.$http.get('/get-external-list',{
            params: {
              group_id: this.group_id,
              page: this.pagination.current,
              per_page: this.pagination.pageSize,
            }
          }).then(res => {
          this.list = res.data.list
           this.pagination.total = res.data.total
        })
      },
      cancel() {
        this.$router.back(-1)
      }
    }
  }
</script>

<style lang="scss" scoped>
  .headimg {
    width: 28px;
    height: 28px;
    border-radius: 50%;
  }


  .form-container {
    padding-bottom: 120px;
  }

  .container {
    .btn {
      margin-right: 30px;
    }
  }

  .tips-c {
    margin-bottom: 20px;
    font-weight: 500;
  }
</style>
